import { QXEvent } from "qx-util";
import { IParam, IDataViewCtrlControllerParams, IDataViewCtrlAbility, DataViewCtrlActionType,  ICtrlEvent, IDataViewCtrlStore,DataViewCtrlController, IDataViewCtrlModel, IDataViewCtrlController } from "@/core";
import { useDataViewAction, useDataViewBasic, useDataViewControllerParams, useDataViewProps } from "@/hooks/widget/use-data-view";
import { Dataviewexpbar_dataviewControlVO } from './card-navigation-data-view-vo';
import { model } from "./card-navigation-data-view-model";
import DataViewService from "@/core/modules/ctrl-service/data-view-service";
// 基于template/src/widgets/{{appEntities}}/{{ctrls@CHART}}-data-view/{{spinalCase ctrl.codeName}}-data-view-hook.ts.hbs生成
/**
 * 获取输入参数
 *
 * @export
 * @return {*}
 */
export function useProps() {
	return {
		...useDataViewProps(),
	};
}

/**
 * 获取基础数据
 *
 * @export
 * @param {*} props
 * @return {*}
 */
export function useBasic(props: any) {
	return {
		...useDataViewBasic(model, props),
	};
}

/**
 * 获取行为
 *
 * @export
 */
export function useAction(controller: any) {
	return {
		...useDataViewAction(controller),
	};
}


/**
 * 获取控制器
 *
 * @export
 * @param {IParam} props
 * @param {QXEvent<ICtrlEvent<DataViewCtrlActionType, IDataViewCtrlAbility>>} evt
 * @return {*}
 */
export function useController(
	props: IParam,
	evt: QXEvent<ICtrlEvent<DataViewCtrlActionType, IDataViewCtrlAbility>>,
    otherParams: IParam = {},
): IDataViewCtrlController<IDataViewCtrlStore, IDataViewCtrlAbility> {
	const params: IDataViewCtrlControllerParams<DataViewCtrlActionType, IDataViewCtrlAbility> =
		useDataViewControllerParams<IDataViewCtrlStore, IDataViewCtrlModel>(model, props, evt, otherParams);
    const ctrlService = new DataViewService<Dataviewexpbar_dataviewControlVO>(Dataviewexpbar_dataviewControlVO, model.entityCodeName, { model });
  	Object.assign(params, { ctrlService });
  	return new DataViewCtrlController(params);
}